package sy.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;

import sy.util.CustomJsonDateSerializer;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * SysAccount entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "wy_account", catalog = "ssh")
public class WYAccount implements java.io.Serializable {

	// Fields

	private String id;
	private String workCode;//工号
	private String name;//手机号码
	private String password;
	private String token;
	private String weChat;
	private Date loginTime;
	private WYRole wyRole;
	private String talkbackUUID;
	private String isFirstLogin;
	
	
	@JsonProperty(value = "wyRoleName")
    private String wyRoleName;
	// Constructors

	/** default constructor */
	public WYAccount() {
	}

	/** full constructor */
	public WYAccount(String id, String name, String password, String token, String weChat, Date loginTime) {
		super();
		this.id = id;
		this.name = name;
		this.password = password;
		this.token = token;
		this.weChat = weChat;
		this.loginTime = loginTime;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "uuid.string")
	@Id
	@Column(name = "id", unique = true, nullable = false, length = 64)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}
	@Column(name = "workCode")
	public String getWorkCode() {
		return workCode;
	}

	public void setWorkCode(String workCode) {
		this.workCode = workCode;
	}

	@Column(name = "name")
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "password")
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	@Column(name = "token")
	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}
	@Column(name = "weChat")
	public String getWeChat() {
		return weChat;
	}

	public void setWeChat(String weChat) {
		this.weChat = weChat;
	}
	@Column(name = "loginTime")
	@JsonDeserialize(using = CustomJsonDateSerializer.class)  
	public Date getLoginTime() {
		return loginTime;
	}

	public void setLoginTime(Date loginTime) {
		this.loginTime = loginTime;
	}
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "wyRole")
	public WYRole getWyRole() {
		return wyRole;
	}

	public void setWyRole(WYRole wyRole) {
		this.wyRole = wyRole;
	}
	
	@Transient
	public String getWyRoleName() {
		if (getWyRole()==null){
			return "";
		}
		return getWyRole().getName();
	}

	public void setWyRoleName(String wyRoleName) {
		this.wyRoleName = wyRoleName;
	}
	@Column(name = "talkbackUUID")
	public String getTalkbackUUID() {
		return talkbackUUID;
	}

	public void setTalkbackUUID(String talkbackUUID) {
		this.talkbackUUID = talkbackUUID;
	}
	@Column(name = "isFirstLogin")
	public String getIsFirstLogin() {
		return isFirstLogin;
	}

	public void setIsFirstLogin(String isFirstLogin) {
		this.isFirstLogin = isFirstLogin;
	}
	


}